package br.com.webcrm.view;

import java.util.List;

import br.com.webcrm.model.Motivo;

@SuppressWarnings("serial")
public class MotivoDataModel extends PrimeDataModel<Motivo> {

    public MotivoDataModel() {
    }

    public MotivoDataModel(Object data) {
        super(data);
    }
    
    @SuppressWarnings("unchecked")
	@Override
    public Motivo getRowData(String rowKey) {
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data
        
        List<Motivo> motivos = (List<Motivo>) getWrappedData();
        
        for(Motivo motivo : motivos) {
        	String id = ""+motivo.getIdMotivo();
            if(id.equals(rowKey))
                return motivo;
        }
        
        return null;
    }

    @Override
    public String getRowKey(Motivo motivo) {
        return ""+motivo.getIdMotivo();
    }
}
                    
